-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve docs and add build() method to {Null,Boolean,}BufferBuilder
#9155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| /// | ||
| /// `NullBuffer`s can be creating using [`NullBufferBuilder`] | ||
| /// # See also | ||
| /// * [`NullBufferBuilder`] for creating `NullBuffer`s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding some comments here to help navigate the maze of builders available
| /// | ||
| /// This consumes the builder. Use [`Self::finish`] to reuse it. | ||
| #[inline] | ||
| pub fn build(self) -> BooleanBuffer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most builders have a build method. The fact that the *Buffer builders in the crate do not is a small source of API friction I would like to remove
| /// This builder only materializes the buffer when we append `false`. | ||
| /// If you only append `true`s to the builder, what you get will be | ||
| /// `None` when calling [`finish`](#method.finish). | ||
| /// This builder only materializes the buffer when null values (`false`) are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive by wording cleanup
| /// | ||
| /// # See Also | ||
| /// | ||
| /// * [`NullBuffer`] for building [`BooleanBuffer`]s for representing nulls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NullBufferBuilder is the correct reference so I fixed that
7fa4c47 to
b2e5fe4
Compare
{Null,Boolean,}BufferBuilder
scovich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
arrow-buffer/src/builder/null.rs
Outdated
| self.bitmap_builder | ||
| .map(|mut builder| NullBuffer::new(builder.finish())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aside: Is there an impl From that would allow this?
| self.bitmap_builder | |
| .map(|mut builder| NullBuffer::new(builder.finish())) | |
| self.bitmap_builder.map(Into::into) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call -- done in b844e5a
etseidl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alamb, just a few nits.
Co-authored-by: Ed Seidl <[email protected]>
|
Thanks again everyone |
Which issue does this PR close?
ArrayData(1% improvement) #9120Rationale for this change
I am trying to encourage people to avoid using ArrayData when constructing arrays (as it is slower than just creating the arrays directly). Part of doing so is ensuring that the APIs to create the necessary pieces (NullBuffers in particular) are easy to use / well documented.
As pointed out by @scovich on #9120 (comment), it is
finishworks (resets the builder)buildmethod (when there is a From impl)Thus, let's add
buildmethods toNullBufferBuilderand document the difference betweenfinishandbuildWhile I was working on this change, I noticed the same issue with
BufferBuilderandBooleanBufferBuilderso I also made them consistentWhat changes are included in this PR?
Are these changes tested?
Yes by CI and new doc examples
Are there any user-facing changes?